﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HZ.Supervise.Model;

namespace HZ.Supervise.Web.Message
{
    public partial class Message : System.Web.UI.Page
    {
        IBLL.IBLL_MessageTypeDetail ibllMessage = new BLL.BLL_MessageTypeDetail();
        /// <summary>
        /// 编号
        /// </summary>
        public string OrderDetailId
        {
            get
            {
                string orderDetailId = "";
                if (Request.QueryString["orderDetailId"] != null)
                    orderDetailId = Request.QueryString["orderDetailId"].ToString();
                return orderDetailId;
            }
        }



        public string OrderName
        {
            get
            {
                string orderName = "";
                if (Request.QueryString["orderName"] != null)
                    orderName = Request.QueryString["orderName"].ToString();
                return orderName;
            }
        }

        /// <summary>
        /// 医院
        /// </summary>
        public string HospitalName
        {
            get
            {
                string hospitalName = "";
                if (Request.QueryString["hospitalName"] != null)
                    hospitalName = Request.QueryString["hospitalName"].ToString();
                return hospitalName;
            }
        }

        /// <summary>
        /// 地区
        /// </summary>
        public string AreaName
        {
            get
            {
                string areaName = "";
                if (Request.QueryString["areaName"] != null)
                    areaName = Request.QueryString["areaName"].ToString();
                return areaName;
            }
        }



        public int TypeId
        {
            get
            {
                int typeId = 0;
                if (Request.QueryString["typeId"] != null)
                    int.TryParse(Request.QueryString["typeId"].ToString(), out typeId);
                return typeId;
            }
        }
        public string _strSqlWhere = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //配送企业已发货未开票
                if (TypeId == 9)
                {
                    Bind9();
                }
                //配送企业已确认采购单未发货
                else if (TypeId == 8)
                {
                    Bind8();
                }
                //企业已提交配送企业未确认
                else if (TypeId == 3)
                {
                    Bind3();
                }
                //医院已入库未回款
                else if (TypeId == 7)
                {
                    Bind7();
                }
                //配送企业已确认医院未入库
                else if (TypeId == 6)
                {
                    Bind6();
                }
                //医院已提交退货单配送企业未确认
                else if (TypeId == 4)
                {
                    Bind4();
                }
                //医院已结算配送企业未确认
                else if (TypeId == 5)
                {
                    Bind5();
                }
                //医院药品监控
                else if (TypeId == 1)
                {
                    Bind1();
                }
            }
        }

        public void Bind9()
        {
            div8.Visible = false;
            div9.Visible = true;
            div3.Visible = false;
            div7.Visible = false;
            div6.Visible = false;
            div4.Visible = false;
            div5.Visible = false;
            div1.Visible = false;
            int count = 0;
            DataTable dt = ibllMessage.GetBllByType9(OrderDetailId, HospitalName, AreaName, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out count);
            if (dt.Rows.Count > 0)
            {
                gv1.DataSource = dt;
                gv1.DataBind();
                AspNetPager1.RecordCount = count;
                divInfo.Visible = false;
            }
            else
                divInfo.Visible = true;
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            Bind9();
        }


        public void Bind8()
        {
            div8.Visible = true;
            div9.Visible = false;
            div3.Visible = false;
            div7.Visible = false;
            div6.Visible = false;
            div4.Visible = false;
            div5.Visible = false;
            div1.Visible = false;
            int count = 0;
            DataTable dt = ibllMessage.GetBllByType8(OrderDetailId, HospitalName, AreaName, AspNetPager2.CurrentPageIndex, AspNetPager2.PageSize, out count);
            if (dt.Rows.Count > 0)
            {
                gv2.DataSource = dt;
                gv2.DataBind();
                AspNetPager2.RecordCount = count;
                divInfo.Visible = false;
            }
            else
                divInfo.Visible = true;
        }

        protected void AspNetPager2_PageChanged(object sender, EventArgs e)
        {
            Bind8();
        }


        public void Bind3()
        {
            div8.Visible = false;
            div9.Visible = false;
            div3.Visible = true;
            div7.Visible = false;
            div6.Visible = false;
            div4.Visible = false;
            div5.Visible = false;
            div1.Visible = false;
            int count = 0;
            DataTable dt = ibllMessage.GetBllByType3(OrderDetailId, HospitalName, AreaName, AspNetPager3.CurrentPageIndex, AspNetPager3.PageSize, out count);
            if (dt.Rows.Count > 0)
            {
                gv3.DataSource = dt;
                gv3.DataBind();
                AspNetPager3.RecordCount = count;
                divInfo.Visible = false;
            }
            else
                divInfo.Visible = true;
        }

        protected void AspNetPager3_PageChanged(object sender, EventArgs e)
        {
            Bind3();
        }

        public void Bind7()
        {
            div8.Visible = false;
            div9.Visible = false;
            div3.Visible = false;
            div7.Visible = true;
            div6.Visible = false;
            div4.Visible = false;
            div5.Visible = false;
            div1.Visible = false;
            int count = 0;
            DataTable dt = ibllMessage.GetBllByType7(OrderDetailId, HospitalName, AreaName, AspNetPager4.CurrentPageIndex, AspNetPager4.PageSize, out count);
            if (dt.Rows.Count > 0)
            {
                gv4.DataSource = dt;
                gv4.DataBind();
                AspNetPager4.RecordCount = count;
                divInfo.Visible = false;
            }
            else
                divInfo.Visible = true;
        }

        protected void AspNetPager4_PageChanged(object sender, EventArgs e)
        {
            Bind7();
        }



        public void Bind6()
        {
            div8.Visible = false;
            div9.Visible = false;
            div3.Visible = false;
            div7.Visible = false;
            div6.Visible = true;
            div4.Visible = false;
            div5.Visible = false;
            div1.Visible = false;
            int count = 0;
            DataTable dt = ibllMessage.GetBllByType6(OrderDetailId, HospitalName, AreaName, AspNetPager5.CurrentPageIndex, AspNetPager5.PageSize, out count);
            if (dt.Rows.Count > 0)
            {
                gv5.DataSource = dt;
                gv5.DataBind();
                AspNetPager5.RecordCount = count;
                divInfo.Visible = false;
            }
            else
                divInfo.Visible = true;
        }

        protected void AspNetPager5_PageChanged(object sender, EventArgs e)
        {
            Bind6();
        }

        public void Bind4()
        {
            div8.Visible = false;
            div9.Visible = false;
            div3.Visible = false;
            div7.Visible = false;
            div6.Visible = false;
            div4.Visible = true;
            div5.Visible = false;
            div1.Visible = false;
            int count = 0;
            DataTable dt = ibllMessage.GetBllByType4(OrderDetailId, HospitalName, AreaName, AspNetPager6.CurrentPageIndex, AspNetPager6.PageSize, out count);
            if (dt.Rows.Count > 0)
            {
                gv6.DataSource = dt;
                gv6.DataBind();
                AspNetPager6.RecordCount = count;
                divInfo.Visible = false;
            }
            else
                divInfo.Visible = true;
        }

        protected void AspNetPager6_PageChanged(object sender, EventArgs e)
        {
            Bind4();
        }


        public void Bind5()
        {
            div8.Visible = false;
            div9.Visible = false;
            div3.Visible = false;
            div7.Visible = false;
            div6.Visible = false;
            div4.Visible = false;
            div5.Visible = true;
            div1.Visible = false;
            int count = 0;
            DataTable dt = ibllMessage.GetBllByType5(OrderDetailId, HospitalName, AreaName, AspNetPager7.CurrentPageIndex, AspNetPager7.PageSize, out count);
            if (dt.Rows.Count > 0)
            {
                gv7.DataSource = dt;
                gv7.DataBind();
                AspNetPager7.RecordCount = count;
                divInfo.Visible = false;
            }
            else
                divInfo.Visible = true;
        }

        protected void AspNetPager7_PageChanged(object sender, EventArgs e)
        {
            Bind5();
        }


        public void Bind1()
        {
            div8.Visible = false;
            div9.Visible = false;
            div3.Visible = false;
            div7.Visible = false;
            div6.Visible = false;
            div4.Visible = false;
            div5.Visible = false;
            div1.Visible = true;
            int count = 0;
            DataTable dt = ibllMessage.GetMedicinModel(HospitalName, OrderName, AspNetPager8.CurrentPageIndex, AspNetPager8.PageSize, out count);
            if (dt.Rows.Count > 0)
            {
                gv8.DataSource = dt;
                gv8.DataBind();
                AspNetPager8.RecordCount = count;
                divInfo.Visible = false;
            }
            else
                divInfo.Visible = true;
        }

        protected void AspNetPager8_PageChanged(object sender, EventArgs e)
        {
            Bind1();
        }
    }
}
